extends Area2D

var background
enum State {DOCK, BAR}
var state = State.DOCK
var selected_type = "peaShooter"
var background_pics = {
	"sunFlower": preload("res://asserts/graphic/Cards/card_sunflower.png"),
	"peaShooter" : preload("res://asserts/graphic/Cards/card_peashooter.png"),
}
var level

func _ready():
	background = $background
	background.texture = background_pics[selected_type]
	self.input_event.connect(_on_input_event)

func _on_input_event(viewport, event, shape_idx):
	if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
		if event.pressed:
			if state == State.DOCK:
				level.copy_to_bar(selected_type,position)
				await get_tree().create_timer(0.2).timeout
				$mask.visible = true
			else:
				level.virtual_plant = true
				level.copy_to_ground(selected_type,position)
				
		
